home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / bipl.zip / PROCS.ZIP / HOSTNAME.ICN < prev    next >
Text File  |  1992-09-28  |  1KB  |  50 lines

  1. ############################################################################
  2. #
  3. #    File:     hostname.icn
  4. #
  5. #    Subject:  Procedures to produce host name
  6. #
  7. #    Author:   Richard L. Goerwitz
  8. #
  9. #    Date:     June 1, 1991
  10. #
  11. ###########################################################################
  12. #
  13. #    Version:  1.1
  14. #
  15. ###########################################################################
  16. #  
  17. #  This procedure determines the name of the current host.  It takes no
  18. #  arguments.  Aborts with an error message if the necessary commands
  19. #  are not found.  Geared specifically for UNIX machines.
  20. #
  21. ############################################################################
  22. #
  23. #  Requires: UNIX, pipes
  24. #
  25. ############################################################################
  26.  
  27. procedure hostname()
  28.  
  29.     static h_name
  30.     initial {
  31.     (find("UNIX",&features), find("pipes",&features)) |
  32.         stop("hostname:  works only under UNIX")
  33.     close(open(fname <- "/usr/bin/hostname"|"/bin/uuname"|"/bin/uname"))
  34.         fname := {
  35.         case \fname of {
  36.         "/usr/bin/hostname" :  "/usr/bin/hostname"
  37.         "/usr/bin/uuname"   :  "/usr/bin/uuname -l"
  38.         "/bin/uname"        :  "/bin/uname -n"
  39.             } | "/usr/bin/uuname -l"
  40.     }
  41.     get_name := open(fname, "pr") |
  42.         stop("hostname:  can't find hostname/uuname/uname commands")
  43.         h_name := !get_name
  44.         close(get_name)
  45.     }
  46.  
  47.     return h_name
  48.  
  49. end
  50.